// Copyright (c)  YISH. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.

using System;
using NSQL.Expressions;
using NSQL.Statements;

namespace NSQL.Extensions
{
    public static class SqlObjectExtensions
    {
        public static string ToNpgsql(this ISqlObject sqlObject)
        {
            switch (sqlObject)
            {
                case null: return null;
                case IStatement statement: return statement.ToNpgsql();
                case IExpression expression: return expression.ToNpgsql();
                default:
                    throw new NotSupportedException();
            }
        }

        public static string ToOracle(this ISqlObject sqlObject)
        {
            switch (sqlObject)
            {
                case null: return null;
                case IStatement statement: return statement.ToOracle();
                case IExpression expression: return expression.ToOracle();
                default:
                    throw new NotSupportedException();
            }
        }

        public static string ToMySql(this ISqlObject sqlObject)
        {
            switch (sqlObject)
            {
                case null: return null;
                case IStatement statement: return statement.ToMySql();
                case IExpression expression: return expression.ToMySql();
                default:
                    throw new NotSupportedException();
            }
        }

        public static string ToSqlServer(this ISqlObject sqlObject)
        {
            switch (sqlObject)
            {
                case null: return null;
                case IStatement statement: return statement.ToSqlServer();
                case IExpression expression: return expression.ToSqlServer();
                default:
                    throw new NotSupportedException();
            }
        }

        public static string ToSQLite(this ISqlObject sqlObject)
        {
            switch (sqlObject)
            {
                case null: return null;
                case IStatement statement: return statement.ToSQLite();
                case IExpression expression: return expression.ToSQLite();
                default:
                    throw new NotSupportedException();
            }
        }

        public static string ToSql(this ISqlObject sqlObject)
        {
            switch (sqlObject)
            {
                case null: return null;
                case IStatement statement: return statement.ToSql();
                case IExpression expression: return expression.ToSql();
                default:
                    throw new NotSupportedException();
            }
        }
    }
}